package com.gewu.pm.ui.activity.home;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.viewpager.widget.ViewPager;

import com.androidkun.xtablayout.XTabLayout;
import com.gewu.pm.R;
import com.gewu.pm.app.AppActivity;
import com.gewu.pm.app.AppFragment;
import com.gewu.pm.ui.activity.filter.FilterMultipleActivity;
import com.gewu.pm.ui.fragment.home.DistributorSalesAreaFragment;
import com.gewu.pm.ui.fragment.home.DistributorSalesDistributorFragment;
import com.hjq.base.FragmentPagerAdapter;

/**
 * 配送商销售分析报表
 */
public class ReportDistributorSalesActivity extends AppActivity {

    private XTabLayout mTabLayout;
    private ViewPager mViewPager;
    private FragmentPagerAdapter<AppFragment<?>> mPagerAdapter;

    public static void start(Context context) {
        Intent intent = new Intent(context, ReportDistributorSalesActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_distributor_sales_report;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        mTabLayout = findViewById(R.id.xtl_tabs);
        mViewPager = findViewById(R.id.vp_content);
    }

    @Override
    protected void initData() {
        mPagerAdapter = new FragmentPagerAdapter<>(this);
        mPagerAdapter.addFragment(DistributorSalesDistributorFragment.newInstance(), "配送商");
        mPagerAdapter.addFragment(DistributorSalesAreaFragment.newInstance(0), "销售区域");
        mViewPager.setAdapter(mPagerAdapter);

        // 关联XTabLayout和ViewPager
        mTabLayout.setupWithViewPager(mViewPager);
    }

    @Override
    public void onRightClick(View view) {
        super.onRightClick(view);
        FilterMultipleActivity.start(getActivity());
    }
}